import request from "../utils/request.js";
import {encrypt} from "@/utils/jsencrypt.js";


export function checkUsername(userName){
    return request({
        url: '/reset/checkUserName',
        method: 'get',
        params: {
            userName
        }
    })
}

export function checkUserEmail(userName,email){
    return request({
        url: '/reset/checkEmail',
        method: 'get',
        params: {
            userName,
            email
        }
    })
}

export function sendEmailCode(email){
    return request({
        url: '/reset/sendCode',
        method: 'get',
        params: {
            email
        }
    })
}

export function resetPassword(data){
    data.password = encrypt(data.password)
    return request({
        url: '/reset',
        method: 'post',
        data: {
            ...data
        }
    })
}
